<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }
      body {
        background-color: black;
      }
      ul {
        display: flex;
        list-style: none;
      }
      .box {
        width: 600px;
        height: 200px;
        background-color: #fff;
      }
      ul li {
        flex: 1;
        background-color: red;
        height: 200px;
        border-radius: 50%;
      }
      ul li:nth-child(1) {
        background-color: #ec7c7c;
      }
      ul li:nth-child(2) {
        background-color: greenyellow;
      }
      ul li:nth-child(3) {
        background-color: #e6e69f;
      }
      ul li:nth-child(4) {
        background-color: skyblue;
        font-size: 80px;
        text-align: center;
        line-height: 200px;
        border-radius: 0;
      }

      .box ul .red {
        background-color: red;
      }
      .box ul .green {
        background-color: green;
      }
      .box ul .yellow {
        background-color: yellow;
      }
    </style>
  </head>
  <body>
    <div class="box">
      <ul>
        <li class=""></li>
        <li class=""></li>
        <li class=""></li>
      
      </ul>
    </div>
    <script>
      function red() {
        document.querySelector("ul li:nth-child(1)").classList.add("red");
        document.querySelector("ul li:nth-child(3)").classList.remove("yellow");
      }
      function green() {
        document.querySelector("ul li:nth-child(1)").classList.remove("red");
        document.querySelector("ul li:nth-child(2)").classList.add("green");
      }
      function yellow() {
        document.querySelector("ul li:nth-child(2)").classList.remove("green");
        document.querySelector("ul li:nth-child(3)").classList.add("yellow");
      }

      function dd(clas,timer) {
      
        return new Promise((resolve, reject) => {
         
            setTimeout(()=>{
          if (clas === "red") {
            red();
           
          } else if (clas === "green") {
            green();
           
          } else if (clas === "yellow") {
            yellow();
           
          }
          resolve()
        },timer);
       })
      }

      async function ll() {
        
           await dd('red',2000);
           await dd('green',2000);
           await dd('yellow',2000);
        ll()
      }

      ll();
    </script>
  </body>
</html>